package moodish.client;

import moodish.client.gui.MoodishClientGui;
import moodish.comm.ClientComm;

public class MessageHendler extends Thread {

	private ClientComm comm;
	private MoodishClientGui gui;

	/**
	 * @param comm2
	 * @param gui
	 */
	public MessageHendler(ClientComm comm2, MoodishClientGui gui){
		this.gui = gui;
		this.comm = comm2;
	}

	@Override
	public void run() {
		super.run();
		try {
			while(comm.isConnected()){
				if(comm.hasNextMessage()){
					gui.getMoodishMessage().newMessage(comm.getNextMessage());
				}
				Thread.sleep(2000);
			}
		}
		catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
